import java.util.Scanner;

class Login {
    public String userName = "admit";
    public String passWord = "123456";
    public void login(String userName,String passWord) {
        if(!this.userName.equals(userName)) {
            System.out.println("用户名错误！");
            throw new UserNameException("用户名错误！");
        }
        if (!this.passWord.equals(passWord)) {
            System.out.println("密码错误！");
            throw new PassWordException("密码错误！");
        }
    }
}
public class Member {
    public static void main(String[] args) {
        int i = 0;
        while (i<3) {
            Scanner scanner = new Scanner(System.in);
            try {
                String userName = scanner.nextLine();
                String passWord = scanner.nextLine();
                Login user = new Login();
                user.login(userName, passWord);

            } catch (UserNameException e) {
                e.printStackTrace();
                System.out.println("捕获到用户名异常...");
                System.out.println("请重新输入用户名和密码:");
            } catch (PassWordException e) {
                e.printStackTrace();
                System.out.println("捕获到密码异常...");
                System.out.println("请重新输入用户名和密码:");
            } finally {
                System.out.println("程序继续执行...");
                i++;
                }
           if (i==3) {
                System.out.println("输入错误超过3次，退出系统!");
            }
        }
    }
}
